<?php
/**
 * Created by PhpStorm.
 * User: CYJiao
 * Date: 6/18/15
 * Time: 22:26
 */

?>

<style>
    .table-patient table{border-right:1px dashed #EEEEEE;border-bottom:1px dashed #EEEEEE}
    .table-patient table td{border-left:1px dashed #EEEEEE;border-top:1px dashed #EEEEEE}
    .table-patient table th{border-left:1px dashed #EEEEEE;border-top:1px dashed #EEEEEE}
</style>

<script>
    function save(){
        if($("#disease_days").val() == ""){
            $("#error_disease_days").html('发病天数不能为空');
            return false;
        }else{
            $("#error_disease_days").html('');
        }

        if($("#outpatient_complaint").val() == ""){
            $("#error_outpatient_complaint").html('患者主诉不能为空');
            return false;
        }else{
            $("#error_outpatient_complaint").html('');
        }
        $.ajax({
            type: 'POST',
            url: '<?php echo CController::createUrl('eHR/savePatientEHR') ;?>',
            data: $('#form-ehr').serialize(),
            success: function(data){
                if(data.status==0){
                    alert('保存成功！\n你可以在历史病历中查询患者历史记录。');
                    addPatientTab('历史病历','<?php echo Yii::app()->request->baseUrl; ?>/index.php?r=eHR/getPatientEHRContent&pk_outpatient_ehr_id='+data.result,'icon-ehr');
                }else{
                    alert('保存失败！\n请添加完整信息，谢谢！');
                }
            },
            dataType: 'json'
        });
    }
</script>

<div class="easyui-panel" data-options="border:false,fit:true" style="padding:5px;">
    <div class="easyui-panel" data-options="border:false" style="width:100%;height:36px;background:#fafafa;margin-bottom: 10px;padding-top:5px;padding-left: 5px;">
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="save();">保存病历</a>
    </div>
    <div class="easyui-panel" data-options="border:false" style="width:100%;height:30px;background:#fafafa;margin-bottom: 5px;">
        <div class="easyui-layout" data-options="border:false,fit:true">
           <div data-options="region:'west',border:false" style="width:33%;padding:5px;">患者姓名：&nbsp;&nbsp;<?php echo $outpatient['true_name'];?></div>
            <div data-options="region:'center',border:false" style="padding:5px;">患者性别：&nbsp;&nbsp;<?php
                                if($outpatient['gender']==1){
                                    echo '男';
                                }else if($outpatient['gender']==2){
                                    echo '女';
                                }else {
                                    echo '保密';
                                }
                            ?></div>
            <div data-options="region:'east',border:false" style="width:33%;padding:5px;">患者年龄：&nbsp;&nbsp;<?php echo age($outpatient['dob']);?></div>
        </div>
    </div>
    <form id="form-ehr" method="post">
        <input type="hidden" name="fk_outpatient_id" value="<?php echo $pk_outpatient_id; ?>"/>
        <div class="easyui-accordion" data-options="multiple:true"  style="width:100%;">
            <div title="患者信息" data-options="selected:false" style="overflow:auto;padding:10px;">
            <div class="easyui-panel" style="width:100%;padding:5px;background:#fafafa;margin-bottom: 10px;">
            <div class="table-patient">
                <table style="width:100%;">
                    <tbody>
                    <tr>
                        <th align="right">真实姓名：</th>
                        <td><?php echo $outpatient['true_name'];?></td>
                        <th align="right">性别：</th>
                        <td>
                            <?php
                                if($outpatient['gender']==1){
                                    echo '男';
                                }else if($outpatient['gender']==2){
                                    echo '女';
                                }else {
                                    echo '保密';
                                }
                            ?>
                        </td>
                        <th align="right">电话：</th>
                        <?php if($outpatient['phone']!=NULL):?>
                            <td><?php echo $outpatient['phone'];?></td>
                        <?php else: ?>
                            <td><input class="easyui-textbox" name="phone" value="<?php echo $outpatient['phone'];?>"/></td>
                        <?php endif; ?>
                    </tr>
                    <tr>
                        <!--<th align="right">生日：</th>
                        <td><input class="easyui-datebox" name="dob" value="<?php echo $outpatient['dob'];?>"/></td>-->
                        <th align="right">年龄：</th>
                        <?php
                            $age = age($outpatient['dob']);
                        ?>
                        <td><?php echo $age;?></td>
                        <th align="right">职业：</th>
                        <td><input class="easyui-textbox" style="" name="occupation" value="<?php echo $outpatient['occupation'];?>"></td>
                    </tr>
                    <tr>
                        <th align="right">住址：</th>
                        <td colspan="5"><input class="easyui-textbox" style="width:50%" name="location" value="<?php echo $outpatientLocation['address'];?>"></td>
                    </tr>
                    <tr>
                        <th align="right">体重：</th>
                        <td><input class="easyui-textbox" style="" name="weight" value="<?php echo $outpatient['weight'];?>">&nbsp;kg</td>
                        <th align="right">身高：</th>
                        <td><input class="easyui-textbox" style="" name="stature" value="<?php echo $outpatient['stature'];?>">&nbsp;cm</td>
                        <th align="right">民族：</th>
                        <td><input class="easyui-textbox" style="" name="blood_type" value="<?php echo $outpatient['occupation'];?>"></td>
                    </tr>
                    <tr>
                        <th align="right">饮酒：</th>
                        <td>
                            <select class="" name="alcohol">
                                <option value="1" <?php if($outpatient['alcohol']==1) echo 'selected';?>>无</option>
                                <option value="2" <?php if($outpatient['alcohol']==2) echo 'selected';?>>很少</option>
                                <option value="3" <?php if($outpatient['alcohol']==3) echo 'selected';?>>有时</option>
                                <option value="4" <?php if($outpatient['alcohol']==4) echo 'selected';?>>经常</option>
                                <option value="5" <?php if($outpatient['alcohol']==5) echo 'selected';?>>总是</option>
                            </select>
                        </td>
                        <th align="right">吸烟：</th>
                        <td><input class="easyui-textbox" style="width:50px;" name="smoke" value="<?php if($outpatient['smoke']==NULL) echo '0'; else echo $outpatient['smoke']; ?>"> 支/天</td>
                        <th align="right">血型：</th>
                        <td>
                            <select class="" name="blood_type">
                                <option value="1" <?php if($outpatient['blood_type']==1) echo 'selected';?>>A</option>
                                <option value="2" <?php if($outpatient['blood_type']==2) echo 'selected';?>>B</option>
                                <option value="3" <?php if($outpatient['blood_type']==3) echo 'selected';?>>AB</option>
                                <option value="4" <?php if($outpatient['blood_type']==4) echo 'selected';?>>O</option>
                            </select>
                        </td>
                    </tr>
                   
                    </tbody>
                </table>
            </div>
        </div>
            </div>
            <div title="病历" data-options="selected:true" data-options="iconCls:'icon-ehr'" style="padding:10px;">
            <div title="病历" data-options="iconCls:'icon-ehr'" style="padding:5px;">
                <table cellpadding="5" style="width:100%;">
                    <tr>
                        <td style="width:100px;">过敏史：</td>
                        <td colspan="5"><input class="easyui-textbox" style="width:50%" name="allergy" value="<?php echo $outpatient['allergy'];?>"></td>
                    </tr>
                    <tr>
                        <td style="width:100px;">患者主诉:</td>
                        <td><input class="easyui-textbox" type="text" name="outpatient_complaint" data-options="multiline:true" id="outpatient_complaint" style="width:70%;height:70px;"  value=""/><span id="error_outpatient_complaint" style="color:red;"></td>
                    </tr>
                    <tr style="background-color: #F7F7F7">
                        <!--<td>发病天数:</td>
                        <td><input class="easyui-textbox" type="text" name="disease_time" data-options="" style="width:50px;" id="disease_time"/> 天<span id="disease_time" style="color:red;"></span></td>-->
                    </tr>
                    <tr>
                        <td>现病史:</td>
                        <td><input class="easyui-textbox" type="text" name="current_ill" data-options="multiline:true" style="width:70%;height:70px;" /></td>
                    </tr>
                    <tr >
                        <td>既往病史:</td>
                        <td><input class="easyui-textbox" type="text" name="previous_ill_history" data-options="multiline:true" style="width:70%;height:70px;" /></td>
                    </tr>
                </table>
                 <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="save();">保存病历</a>
            </div>
            </div>
        </div>


    </form>
</div>
